Attribute Grammars and Functional Programming Deforestation
نویسندگان
چکیده
The functional programming community is paying increasing attention to static structure-based transformations. For example, generic control operators , such as fold, have been introduced in functional programming to increase the power and applicability of a particular kind of static transformation, called deforestation, which prevents the construction of useless intermediate data structures in function composition. This is achieved by making the structure of the data more explicit in program speciications. We argue that one of the original concepts of Attribute Grammars is precisely to make data structures explicit in program speciications. Furthermore, there exists a powerful static deforestation-like transformation in their context. In this paper, we present similarities between deforestation methods, on the one hand with the functional approach, and on the other hand with the Attribute Grammars approach. In order to gain a grasp of these similarities, we rst make a simple comparison: purely-synthesized Attribute Grammars and rst order folds. In this context, deforestation transformations are equivalent. This allows us to highlight the limitations of the fold formalism and to present how the hy-lomorphism approach generalizes it; hylomorphisms and attribute grammars are surprisingly alike. Finally, we show how the inherited attribute notion in Attribute Grammars solves some transformation problems in higher order functional programs.
منابع مشابه
Structure-directed Genericity in Functional Programming and Attribute Grammars
Generic control operators, such as fold, have been introduced in functional programming to increase the power and applicability of data-structure-based transformations. This is achieved by making the structure of the data more explicit in program speciications. We argue that this very important property is one of the original concepts of attribute grammars. In this paper, we present the similar...
متن کاملAttribute Grammars and Folds : Generic Control Operators
Generic control operators, such as fold, have been introduced in functional programming to increase the power and applicability of data-structure-based transformations. This is achieved by making the structure of the data more explicit in program speciications. We argue that this very important property is one of the original concepts of attribute grammars. In this paper, we informally show the...
متن کاملHow to Deforest in Accumulative Parameters?
Software engineering has to reconcile modularity with ee-ciency. One way to grapple with this dilemma is to automatically transform a modular-speciied program into an eecient-implementable one. This is the aim of deforestation transformations which get rid of intermediate data structures constructions that appear when two functions are composed. Nevertheless, existing functional methods cannot ...
متن کاملDeforesting in Accumulating Parameters via Type-Directed Transformations
Classical deforestation methods fail to compose functions with accumulating parameters, which are function arguments to which intermediate result accumulates. This paper proposes a new deforestation method which solves this problem. The method is comprised of a few transformation steps, each of which is guided by type information. Though our solution draws its fundamental idea from a deforestat...
متن کاملFirst-class Attribute Grammars
This paper is a contribution to the ongoing quest for modular descriptions of language processors, with the specific aim of rapidly prototyping domain-specific languages [21]. Some might argue that this problem was solved in the eighties, with the development of a proliferation of language processors based on attribute grammars [11, 15, 22]. Others might argue that functional programming langua...
متن کامل